﻿using Face8280WebSocketServer.DB.Device;
using Face8280WebSocketServer.Utility.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Face8280WebSocketServer.Service
{
    public class FaceDriveInfoService : BaseService
    {

        public FaceDriveInfoService(DbContext context) : base(context)
        {

        }


        public JsonResultModel AddDevice(DB.Device.FaceDeviceInfo info)
        {
            if (info == null)
            {
                return new JsonResultModel(101, "设备信息不能为空");
            }
            var dbSet = Set<FaceDeviceInfo>();
           
            if(!dbSet.Any(a=>a.DeviceSn.Equals(info.DeviceSn)))
            {
                Insert(info);
            }
            else
            {
                Update(info);
            }
            return new JsonResultModel();

        }
    }
}
